package cn.turboinfo.dongying.api.provider.common.repository.database.user;

import cn.turboinfo.dongying.api.entity.common.enumeration.common.EntityObjectType;
import cn.turboinfo.dongying.api.entity.common.enumeration.user.UserType;
import net.sunshow.toolkit.core.qbean.helper.repository.BaseRepository;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

public interface UserTypeRelDAO extends BaseRepository<UserTypeRelPO, Long> {
    List<UserTypeRelPO> findByUserId(Long userId);

    List<UserTypeRelPO> findByUserIdAndUserType(Long userId, UserType userType);

    List<UserTypeRelPO> findByUserType(UserType userType);

    Long countByUserType(UserType userType);

    List<UserTypeRelPO> findByUserIdAndUserTypeAndObjectType(Long userId, UserType userType, EntityObjectType objectType);

    Optional<UserTypeRelPO> findByUserIdAndUserTypeAndObjectTypeAndObjectId(Long userId, UserType userType, EntityObjectType objectType, Long objectId);

    List<UserTypeRelPO> findByUserTypeAndObjectTypeAndObjectId(UserType userType, EntityObjectType objectType, Long objectId);

    List<UserTypeRelPO> findByUserTypeAndObjectTypeAndObjectIdIn(UserType userType, EntityObjectType objectType, Collection<Long> objectIdCollection);

    Optional<UserTypeRelPO> findByUserIdAndUserTypeAndObjectTypeAndObjectIdAndReferenceId(Long userId, UserType userType, EntityObjectType objectType, Long objectId, Long referenceId);

    Long countByUserTypeAndCreatedTimeBetween(UserType userType, LocalDateTime start, LocalDateTime end);
}
